import csv
from matplotlib import pyplot as plt
from datetime import datetime

filename = "death_valley_2014.csv"
with   open(filename) as file:
    reader = csv.reader(file)
    header_row = next(reader)

    dates = []
    highs = []
    lows = []
    for row in reader:

        try:
            date = datetime.strptime(row[0], "%Y-%m-%d")
            high = int(row[1])
            low = int(row[3])

        except ValueError:
            print(row)
        else:
            dates.append(date)
            highs.append(high)
            lows.append(low)

    figure = plt.figure(dpi=128, figsize=(10, 6))
    plt.plot(dates, highs, c="red")
    plt.plot(dates, lows, c="lightskyblue")
    # 设置图形样式
    plt.title("Daily high temperatures 2014", fontsize=24)
    plt.xlabel('', fontsize=16)
    plt.ylabel("Temperature (F)", fontsize=16)
    plt.tick_params(axis='both', which='major', labelsize=16)

    figure.autofmt_xdate()
    plt.fill_between(dates, highs, lows, facecolor="lightgoldenrodyellow", alpha="0.5")
    plt.show()
